package com.lge.clock.worldclock.cities;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.net.Uri;

import com.lge.clock.worldclock.WorldClockProvider;
import com.lge.clock.worldclock.accuweather.WeatherUtil;
import com.lge.clock.worldclock.util.DataManager;
import com.lge.clock.worldclock.util.DatabaseHelper;
import com.lge.clock.worldclock.util.Log;
import com.lge.clock.worldclock.util.WCPreferences;

/**
 * @author lge.com
 */
public class CityDBManager {
	public static final int CITY_SET_NONE = 0;
	public static final int CITY_SET_SETTED = 1;

	public static final int SEARCH_FIRST_GROUP = 0;
	public static final int SEARCH_SECOND_GROUP = 1;

	public static final String DELETE_WIDGET_URI = "com.lge.worldclock.deletecity";
	private static ArrayList<CityInformation> cityInfoMapList = new ArrayList<CityInformation>();

	private static ArrayList<CityInformation> cityInfoAllList = new ArrayList<CityInformation>();

    private static ArrayList<CityInformation> backup_cityInfoList = null;
	private static CityDBManager sInstance = null;
	private static Context mContext = null;
	private static int mAddCompleteId = -1;

	private static DatabaseHelper mDatabaseHelper = null;

	public static CityDBManager getInstance(Context context) throws IOException {
//		android.util.Log.i("ALARM","CityDBManager.java || getInstance : Context = " + context);
		if (sInstance == null && context != null) {
//			android.util.Log.i("ALARM","CityDBManager.java || getInstance : sInstance is null");
			sInstance = new CityDBManager(context);
		}

		mContext = context;
		initAddCityId();

		//moon.dongchul@lge.com WBT #297442 2012-01-05
		if(!CityInformation.getLanguageMode().equals(CityInformation.languageMode())){
//			android.util.Log.i("ALARM","CityDBManager.java || getInstance : Language is different");
			mDatabaseHelper.close();
			mDatabaseHelper = new DatabaseHelper(context, DatabaseHelper.DATABASE_NAME);
			cityInfoMapList.clear();
			cityInfoAllList.clear();
		}

		return sInstance;
	}

	private CityDBManager(Context context) throws IOException {
//		android.util.Log.i("ALARM","CityDBManager.java || Constructor : Start");
		mDatabaseHelper = new DatabaseHelper(context, DatabaseHelper.DATABASE_NAME);
		WCPreferences WcPref = new WCPreferences(context);

		if((!isExistDatabase(context))
				|| (DatabaseHelper.getDataBaseVer() > WcPref.getDatabaseVersion())) {
//			android.util.Log.i("ALARM","CityDBManager.java || Constructor : Create WorldClock DB");
			createWorldClockDatabaseFile(context);
			WcPref.setDatabaseVersion(DatabaseHelper.getDataBaseVer());
		}

		// for OpenGL Speed Up
		if(getCityInfoMapList().size() == 0) {
			loadCityDataForMap(context);
		}
	}

	public static boolean isExistDatabase(Context context) {
		boolean isExist = false;
		SQLiteDatabase database = null;
		Cursor cursor = null;
		try {
			DatabaseHelper DbHelper = new DatabaseHelper(context, DatabaseHelper.DATABASE_NAME);
			database = DbHelper.getReadableDatabase();
			cursor = database.rawQuery("SELECT COUNT(*) FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME, null);
			if (cursor != null && cursor.moveToNext()) {
				if (cursor.getInt(0) > 0) {
//					android.util.Log.i("ALARM","CityDBManager.java || isExistDatabase : true");
					isExist = true;
				}
			}
		} catch (SQLiteException e) {
			isExist = false;
		} finally {
			if (cursor != null)
				cursor.close();
			if (database != null)
				database.close();
		}

		return isExist;
	}

	private void createWorldClockDatabaseFile(Context context) throws IOException {
		File outfile = new File("/data/data/" + context.getPackageName()
				+ "/databases/", DatabaseHelper.DATABASE_NAME);
		AssetManager assetManager = context.getResources().getAssets();
		ArrayList<CityInformation> backup_cityInfoList = null;

		if (isExistDatabase(context)) {
			backup_cityInfoList = backupWorldClockDatabase(context);
		}

		recreateContentProvider(context);
		
		InputStream inputStream = null;
		BufferedInputStream bufferedInputStream = null;
		FileOutputStream fileOtputStream = null;

		try {
			if (outfile.exists()) {
				outfile.delete();
			}

			inputStream = assetManager.open("database/"
					+ DatabaseHelper.DATABASE_NAME, AssetManager.ACCESS_BUFFER);
			bufferedInputStream = new BufferedInputStream(
					inputStream);
			fileOtputStream = new FileOutputStream(outfile);
			int currentRead = 0;
			//[START]P930_TD#13149_20110721 Fixed the issue that slow reaction from world clok widget  to display city list of world clock by hyunjung78.park
			/*
			if(fileOtputStream != null) {
				currentRead = bufferedInputStream.read();
				while ( currentRead != -1 ) {
					fileOtputStream.write(currentRead);
					currentRead = bufferedInputStream.read();
				}
			}
			*/
			 byte[] buffer = new byte[1024]; 
			 while((currentRead = inputStream.read(buffer)) > 0){
			 	fileOtputStream.write(buffer, 0, currentRead);
			 }
			 //[END]P930_TD#13149_20110721 Fixed the issue that slow reaction from world clok widget  to display city list of world clock by hyunjung78.park
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if(inputStream != null) {
				inputStream.close();
			}
			if(bufferedInputStream != null) {
				bufferedInputStream.close();
			}
			if(fileOtputStream != null) {
				fileOtputStream.close();
			}
		}

		if (backup_cityInfoList != null) {
			resotreWorldClockDatabase(context, backup_cityInfoList);
			copyContentProviderFromWCDB(context);
		}
	}
	
    public static int getWorldClockDBFileSize(Context context) {
    	AssetManager assetManager = context.getResources().getAssets();
    	AssetFileDescriptor fd = null;
		try {
			fd = assetManager.openFd("database/" + DatabaseHelper.DATABASE_NAME);
		} catch (IOException e) {
			e.printStackTrace();
			return 0;
		}
    	return (int)(fd.getLength()/1024);
    }
    
    public static void deleteWorldClockDBFile(Context context) {
        File outfile = new File("/data/data/" + context.getPackageName() + "/databases/",DatabaseHelper.DATABASE_NAME);
        
        if(outfile.exists()) {
        	outfile.delete();
        }
    }
    
    public static InputStream getWorldClockDBInputStream(Context context) {
        File outfile = new File("/data/data/" + context.getPackageName() + "/databases/",DatabaseHelper.DATABASE_NAME);
        AssetManager assetManager = context.getResources().getAssets();
        
        if(isExistDatabase(context)) {
        	backup_cityInfoList = backupWorldClockDatabase(context);
        }
        
        recreateContentProvider(context);
        
        try {
        	if(outfile.exists()) {
        		outfile.delete();
        	}
        	
        	InputStream inputStream = assetManager.open("database/" + DatabaseHelper.DATABASE_NAME, AssetManager.ACCESS_BUFFER); 
        	return inputStream;
        } 
        catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    
    public static FileOutputStream getWorldClockDBFileOutputStream(Context context) {
        File outfile = new File("/data/data/" + context.getPackageName() + "/databases/",DatabaseHelper.DATABASE_NAME);
        
        try {
            FileOutputStream fileOtputStream = new FileOutputStream(outfile);
            return fileOtputStream;
        } 
        catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
    
    public static void closeWorldClockDatabaseFile(Context context, InputStream inputStream, 
    	FileOutputStream fileOutputStream) {    	
    	
		if(inputStream != null) {
			try {
				inputStream.close();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		}
        
		if(fileOutputStream != null) {
			try {
				fileOutputStream.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}		
        
        if(backup_cityInfoList != null) {
        	resotreWorldClockDatabase(context, backup_cityInfoList);
        	backup_cityInfoList = null;
        	copyContentProviderFromWCDB(context);
        }
        
        WCPreferences wcPref = new WCPreferences(context);
        wcPref.setDatabaseVersion(DatabaseHelper.getDataBaseVer());
    }

	private static void resotreWorldClockDatabase(Context context,
			ArrayList<CityInformation> backupCityInfoList) {
		DatabaseHelper databaseHelper = new DatabaseHelper(context,
				DatabaseHelper.DATABASE_NAME);
		SQLiteDatabase database = databaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();

		try {
			for (CityInformation item : backupCityInfoList) {
				values.clear();
				values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT,
						item.getSummerTime());
				values.put(DatabaseHelper.DATABASE_COLUMN_SETTED,
						item.getRegistValue());
				values.put(DatabaseHelper.DATABASE_COLUMN_SETTED_TIME,
						item.getSettedTime());
				values.put(DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE,
						item.getUpdateMode());				
	
				database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
						DatabaseHelper.DATABASE_COLUMN_ID + " = " + item.getID(),
						null);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			database.close();
		}
	}

	private static ArrayList<CityInformation> backupWorldClockDatabase(Context context) {
		DatabaseHelper databaseHelper = new DatabaseHelper(context,
				DatabaseHelper.DATABASE_NAME);
		SQLiteDatabase database = databaseHelper.getReadableDatabase();
		ArrayList<CityInformation> backup_cityInfoList = null;
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_SETTED
				+ " = " + CITY_SET_SETTED;
		Cursor cursor = null;

		try {
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED_TIME + ", "
					+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " "
					+ stringWhere, null);

			if (cursor != null && cursor.moveToFirst()) {
				backup_cityInfoList = new ArrayList<CityInformation>();

				do {
					CityInformation cityInfo = new CityInformation(
							cursor.getInt(0));

					cityInfo.setSummerTime(cursor.getInt(1));
					cityInfo.setRegistValue(cursor.getInt(2));
					cityInfo.setSettedTime(cursor.getInt(3));
					cityInfo.setUpdateMode(cursor.getInt(4));

					backup_cityInfoList.add(cityInfo);
				} while (cursor.moveToNext());
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null)
				cursor.close();
			database.close();
		}
		return backup_cityInfoList;
	}

	public String[] getCityNameAndTimezone(Context context, int cityId) {
		DatabaseHelper databaseHelper = new DatabaseHelper(context,
				DatabaseHelper.DATABASE_NAME);
		SQLiteDatabase database = databaseHelper.getReadableDatabase();

		String[] cityNameAndTimezone = new String[3];
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_ID
				+ " = " + cityId;
		Cursor cursor = null;

		try {
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + stringWhere,
					null);

			if (cursor != null && cursor.moveToFirst()) {
				cityNameAndTimezone[0] = cursor.getString(1);
				cityNameAndTimezone[1] = cursor.getString(2);
				cityNameAndTimezone[2] = cursor.getString(3);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null)
				cursor.close();
			database.close();
		}
		return cityNameAndTimezone;
	}

	public ArrayList<CityInformation> getCityInfoAllList() {
		if (getCityInfoAllListSize() == 0 && mContext != null) {
			loadCityDataForList(mContext);
		}

		return cityInfoAllList;
	}

	public int getCityInfoAllListSize() {
		return cityInfoAllList.size();
	}

	public ArrayList<CityInformation> getCityInfoMapList() {
		if (getCityInfoMapListSize() == 0 && mContext != null) {
			loadCityDataForMap(mContext);
		}

		return cityInfoMapList;
	}

	public int getCityInfoMapListSize() {
		return cityInfoMapList.size();
	}

	public ArrayList<CityInformation> getWorldClockList(Context context) {
		ArrayList<CityInformation> cityInformationList = new ArrayList<CityInformation>();
		SQLiteDatabase databse = mDatabaseHelper.getReadableDatabase();
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_SETTED
				+ " = " + CITY_SET_SETTED;
		String stringOrderBy = "ORDER BY "
				+ DatabaseHelper.DATABASE_COLUMN_SETTED_TIME + " ASC";
		Cursor cursor = null;

		try {
			cursor = databse.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.database_column_city + ", "
					+ DatabaseHelper.database_column_country + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + stringWhere
					+ " " + stringOrderBy, null);

			if (cursor != null && cursor.moveToFirst()) {
				do {
					CityInformation cityInfo = new CityInformation(
							cursor.getInt(0));

					cityInfo.setCityName(cursor.getString(1));
					cityInfo.setCountryName(cursor.getString(2));

					cityInfo.setGmtString(cursor.getString(3));
					cityInfo.setGmtValue(cursor.getInt(4));

					cityInfo.setSummerTime(cursor.getInt(5));
					cityInfo.setRegistValue(cursor.getInt(6));
					cityInfo.setRequest(cursor.getString(7));
					cityInfo.setUpdateMode(cursor.getInt(8));

					cityInformationList.add(cityInfo);
				} while (cursor.moveToNext());

				for (int i = 0; i < cityInformationList.size(); i++) {
					CityInformation cityInfo = cityInformationList.get(i);

					if (isDuplicate(cityInfo)) {
						cityInfo.setDuplicated(true);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null)
				cursor.close();
			databse.close();
		}

		return cityInformationList;
	}

	public int getWCListSize() {
		SQLiteDatabase database = mDatabaseHelper.getReadableDatabase();
		int size = 0;
		Cursor cursor = null;
		String where = "WHERE " + DatabaseHelper.DATABASE_COLUMN_SETTED + " = "
				+ CITY_SET_SETTED;

		try {
			cursor = database.rawQuery("SELECT count("
					+ DatabaseHelper.DATABASE_COLUMN_ID + ") " + "FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + where, null);
			if (cursor != null && cursor.moveToFirst()) {
				size = cursor.getInt(0);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null)
				cursor.close();
			database.close();
		}

		return size;
	}

	public ArrayList<CityInformation> getSearchCityList(String search_keyword,
			int search_type) {
		ArrayList<CityInformation> cityInformationList = new ArrayList<CityInformation>();
		SQLiteDatabase databse = mDatabaseHelper.getReadableDatabase();
		String searching_text = search_keyword.replace("'", "''").trim();
		Cursor cursor = null;

		String table_cities = DatabaseHelper.DATABASE_TABLE_NAME;
		String where = "";
		String sort = "";
		String[] city_query_columns = { DatabaseHelper.DATABASE_COLUMN_ID,
				DatabaseHelper.database_column_city,
				DatabaseHelper.DATABASE_COLUMN_CITY_EN,
				DatabaseHelper.database_column_country,
				DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN,
				DatabaseHelper.DATABASE_COLUMN_GMT_TEXT,
				DatabaseHelper.DATABASE_COLUMN_REQUEST, };

		if (search_type < SEARCH_FIRST_GROUP
				|| search_type > SEARCH_SECOND_GROUP) {
			return null;
		}

		if (search_type == SEARCH_FIRST_GROUP) {
			if (CityInformation.isHangul(searching_text)) { // korean
				where = DatabaseHelper.database_column_city + " LIKE '"
						+ searching_text + "%' or "
						+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY
						+ " LIKE '" + searching_text + "%'";
			} else { // etc
				where = DatabaseHelper.database_column_city + " LIKE '"
						+ searching_text + "%'";
			}
		} else {
			if (CityInformation.isHangul(searching_text)) { // korean
				where = "(" + DatabaseHelper.database_column_city
						+ " NOT LIKE '" + searching_text + "%' and "
						+ DatabaseHelper.database_column_city + " LIKE '%"
						+ searching_text + "%') or ("
						+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY
						+ " NOT LIKE '" + searching_text + "%' and "
						+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY
						+ " LIKE '%" + searching_text + "%') or ("
						+ DatabaseHelper.database_column_city + " NOT LIKE '"
						+ searching_text + "%' and "
						+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY
						+ " NOT LIKE '" + searching_text + "%' and  ("
						+ DatabaseHelper.database_column_country + " LIKE '%"
						+ searching_text + "%' or "
						+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY
						+ " LIKE '%" + searching_text + "%'))";
			} else { // etc
				if((searching_text.compareTo(CityInformation.HANGUL_PARENRHESIS_START_UNICODE) == 0) 
						|| (searching_text.compareTo(CityInformation.HANGUL_PARENRHESIS_END_UNICODE) == 0)){
					where = "(" + DatabaseHelper.database_column_city_en
					+ " NOT LIKE '" + searching_text + "%' and "
					+ DatabaseHelper.database_column_city_en + " LIKE '%"
					+ searching_text + "%') or ("
					+ DatabaseHelper.database_column_city_en + " NOT LIKE '"
					+ searching_text + "%' and "
					+ DatabaseHelper.database_column_country_en + " LIKE '%"
					+ searching_text + "%')";
				}else{
					where = "(" + DatabaseHelper.database_column_city
					+ " NOT LIKE '" + searching_text + "%' and "
					+ DatabaseHelper.database_column_city + " LIKE '%"
					+ searching_text + "%') or ("
					+ DatabaseHelper.database_column_city + " NOT LIKE '"
					+ searching_text + "%' and "
					+ DatabaseHelper.database_column_country + " LIKE '%"
					+ searching_text + "%')";
				}
				
			}
		}

		sort = DatabaseHelper.database_column_city;

		try {
			cursor = databse.query(table_cities, city_query_columns, where,
					null, null, null, sort);
			if (cursor != null && cursor.moveToFirst()) {
				do {
					CityInformation cityInfo = new CityInformation(
							cursor.getInt(0));

					cityInfo.setCityName(cursor.getString(1));
					cityInfo.setEnglishName(cursor.getString(2));

					cityInfo.setCountryName(cursor.getString(3));
					cityInfo.setEnglishCountryName(cursor.getString(4));

					cityInfo.setGmtString(cursor.getString(5));
					cityInfo.setRequest(cursor.getString(6));

					cityInformationList.add(cityInfo);
				} while (cursor.moveToNext());
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null) {
				cursor.close();
				databse.close();
			}
		}

		return cityInformationList;

	}

	public CityInformation getCityInfo(int id) {
		SQLiteDatabase databse = mDatabaseHelper.getReadableDatabase();
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_ID
				+ " = " + id;

		CityInformation cityInfo = new CityInformation(id);
		Cursor cursor = null;

		try {
			cursor = databse.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.database_column_city + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.database_column_country + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + stringWhere
					+ " ", null);

			if (cursor != null && cursor.moveToFirst()) {
				cityInfo.setID(cursor.getInt(0));
				cityInfo.setCityName(cursor.getString(1));
				cityInfo.setEnglishName(cursor.getString(2));

				cityInfo.setCountryName(cursor.getString(3));
				cityInfo.setEnglishCountryName(cursor.getString(4));

				cityInfo.setGmtString(cursor.getString(5));
				cityInfo.setGmtValue(cursor.getInt(6));

				cityInfo.setSummerTime(cursor.getInt(7));
				cityInfo.setRegistValue(cursor.getInt(8));
				cityInfo.setRequest(cursor.getString(9));
				cityInfo.setUpdateMode(cursor.getInt(10));

				if (isDuplicate(cityInfo)) {
					cityInfo.setDuplicated(true);
				}
			}
		} catch (SQLiteException ex) {
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				databse.close();
			}
		}

		return cityInfo;
	}

	public CityInformation getCityInfo(String engCityName) {
		SQLiteDatabase databse = mDatabaseHelper.getReadableDatabase();
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_CITY_EN
				+ " = \"" + engCityName + "\"";
		CityInformation cityInfo = new CityInformation();
		Cursor cursor = null;

		try {
			cursor = databse.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.database_column_city + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.database_column_country + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + stringWhere
					+ " ", null);

			if (cursor != null && cursor.moveToFirst()) {
				cityInfo.setID(cursor.getInt(0));
				cityInfo.setCityName(cursor.getString(1));
				cityInfo.setEnglishName(cursor.getString(2));

				cityInfo.setCountryName(cursor.getString(3));
				cityInfo.setEnglishCountryName(cursor.getString(4));

				cityInfo.setGmtString(cursor.getString(5));
				cityInfo.setGmtValue(cursor.getInt(6));

				cityInfo.setSummerTime(cursor.getInt(7));
				cityInfo.setRegistValue(cursor.getInt(8));
				cityInfo.setRequest(cursor.getString(9));
				cityInfo.setUpdateMode(cursor.getInt(10));

				if (isDuplicate(cityInfo)) {
					cityInfo.setDuplicated(true);
				}
			}
		} catch (SQLiteException ex) {
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				databse.close();
			}
		}

		return cityInfo;
	}
	
	public CityInformation getTimeZoneCityInfo(int id) {
		SQLiteDatabase databse = mDatabaseHelper.getReadableDatabase();
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_ID
				+ " = " + id;
		CityInformation cityInfo = new CityInformation();
		Cursor cursor = null;

		try {
			cursor = databse.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.database_column_city + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.database_column_country + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + stringWhere
					+ " ", null);

			if (cursor != null && cursor.moveToFirst()) {
				cityInfo.setID(cursor.getInt(0));
				cityInfo.setCityName(cursor.getString(1));
				cityInfo.setEnglishName(cursor.getString(2));

				cityInfo.setCountryName(cursor.getString(3));
				cityInfo.setEnglishCountryName(cursor.getString(4));

				cityInfo.setGmtString(cursor.getString(5));
				cityInfo.setGmtValue(cursor.getInt(6));

				cityInfo.setSummerTime(cursor.getInt(7));
				cityInfo.setRegistValue(cursor.getInt(8));
				cityInfo.setRequest(cursor.getString(9));
				cityInfo.setUpdateMode(cursor.getInt(10));

				if (isDuplicate(cityInfo)) {
					cityInfo.setDuplicated(true);
				}
			}
		} catch (SQLiteException ex) {
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				databse.close();
			}
		}

		return cityInfo;
	}

	public boolean daylight(int cityId, int updatemode) {
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();
		Cursor cursor =null;
		String mGmtValue = null;
		int mDayLight = 0;
		String mGmtTime = null;
		try{
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT +	", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " "+ " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
					+ DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);
			
			if (cursor != null && cursor.moveToFirst()) {
				String mCountry = cursor.getString(1);
				String mGetGmt = cursor.getString(2);				
				int osbDaylight = cursor.getInt(3);
				String mRequest = cursor.getString(4);
				int mUpdateModeDB = cursor.getInt(5);
				mGmtValue = WeatherUtil.getGmtString(mGetGmt, mCountry, mRequest, osbDaylight, updatemode, mUpdateModeDB);
				String mNewGmtVale[] = mGmtValue.split("/");
				mDayLight = Integer.parseInt(mNewGmtVale[1]);
				mGmtTime = mNewGmtVale[0];
				
			}
			int result = 0;
			
			values.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, mGmtTime);
			values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, mDayLight);
			values.put(DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE, updatemode);

			result = database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
					DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);

			updateContentProvider(database, cityId);
			
			if (result == 0) {
				return false;
			}
			
		}catch(Exception e){
			Log.message("DB error in CityDBManager");
		}finally{
			// WBT TD#151750 Fixed Start
			if (cursor != null) {
				cursor.close();
			}
			// WBT TD#151750 Fixed End
			database.close();
		}		
		
		return true;
	}

	public boolean addCityInfo(int cityId) {
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentResolver resolver = mContext.getContentResolver();
		ContentValues values = new ContentValues();		
		
		Cursor cursor = null;
		
		int osbDaylight = 0;
		
		String mGmt = null;
		
		cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
					+ DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);
		
		if (cursor != null && cursor.moveToFirst()) {
			mGmt = cursor.getString(1);
			String country = cursor.getString(2);
			String request = cursor.getString(12);
			
			osbDaylight = WeatherUtil.getTimeZoneDaylight(country, request);
		}
		
		int result = 0;		
		int mGmtHour = -1;
		int mGmtMinute = -1;
		String mSign = null;
		
		String newGmtHour = null;
		String newGmtMinute = null;
		String mGmtTime = null;
		
		// [start][yeonju7.kim][IT][WBT_11][P940][45560] 2011.09.08 
		if(mGmt != null) {
		String newGmt[] = mGmt.split(" ");
		String mGmt2 = newGmt[2];
		int mSize = newGmt[2].length();
		if(mSize > 3){
			String newGmtSplit[] = mGmt2.split(":");
			mGmtHour = Integer.parseInt(newGmtSplit[0]);
			mGmtMinute = Integer.parseInt(newGmtSplit[1]);
		}else{
			mGmtHour = Integer.parseInt(newGmt[2]);
		}
		mSign = newGmt[1];
		if(osbDaylight == 1){
			if(mSign.equals("+")){
				mGmtHour = mGmtHour + 1;
			}else{
				mGmtHour = mGmtHour - 1;
			}
		}
		
		if(mGmtMinute == -1){
			newGmtHour = Integer.toString(mGmtHour);
			mGmtTime = newGmt[0] + " " + newGmt[1] + " " +newGmtHour;
		}else{
			newGmtHour = Integer.toString(mGmtHour);
			newGmtMinute = Integer.toString(mGmtMinute);
			mGmtTime = newGmt[0] + " " + newGmt[1] + " " +newGmtHour + ":" + newGmtMinute;
		}
		
		values.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, mGmtTime);
		values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, osbDaylight);
		values.put(DatabaseHelper.DATABASE_COLUMN_SETTED, CITY_SET_SETTED);
		values.put(DatabaseHelper.DATABASE_COLUMN_SETTED_TIME,
				java.lang.System.currentTimeMillis());
		values.put(DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE, 0);

		result = database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
				DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);
		insertContentProvider(database, cityId);

		setAddCityId(cityId);
		//WBT#165164 fixed by mo2sangbong.lee@lge.com 2011.07.30 Start
		try {
			
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			if (database != null) {
				database.close();
			}
			
			if (cursor != null) {
				cursor.close();
			}
		}
		}
		// [end][yeonju7.kim][IT][WBT_11][P940][45560] 2011.09.08 
		//WBT#165164 fixed by mo2sangbong.lee@lge.com 2011.07.30 End
		if (result == 0) {
			return false;
		}
		return true;
	}
	
	public static int getAddCityId() {
		return mAddCompleteId;
	}

	public static void setAddCityId(int cityID) {
		mAddCompleteId = cityID;
	}

	public static void initAddCityId() {
		mAddCompleteId = -1;
	}

	/*
	 * deleteWCItem parameter : CityInformation city_info return : result (true
	 * or false) Description : City unregister to World Clock Main List not
	 * delete item from DB
	 */
	public boolean deleteCity(CityInformation city_info) {
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();
		int result = 0;

		values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, CITY_SET_NONE);
		values.put(DatabaseHelper.DATABASE_COLUMN_SETTED, CITY_SET_NONE);
		values.put(DatabaseHelper.DATABASE_COLUMN_SETTED_TIME, CITY_SET_NONE);
		values.put(DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE, CITY_SET_NONE);

		result = database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
				DatabaseHelper.DATABASE_COLUMN_ID + " = " + city_info.getID(),
				null);

		deleteContentProvider(database, city_info.getID());
		if (database != null)
			try {
				
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				database.close();
			}
		deleteCityBroadCast(city_info, false);
		if (result == 0) {
			return false;
		}
		return true;
	}

	private void deleteAllContentProvider() {
		ContentResolver resolver = mContext.getContentResolver();

		resolver.delete(
				WorldClockProvider.WORLDCLOCK_CONTENT_URI,
				DatabaseHelper.DATABASE_COLUMN_SETTED + " = " + CITY_SET_SETTED,
				null);
	}

	private void deleteContentProvider(SQLiteDatabase database, int cityId) {
		ContentResolver resolver = mContext.getContentResolver();

		Cursor cursor = null;

		try {
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
					+ DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);

			if (cursor != null && cursor.moveToFirst()) {
				resolver.delete(WorldClockProvider.WORLDCLOCK_CONTENT_URI,
						DatabaseHelper.DATABASE_COLUMN_CITY_EN + " = \""
								+ cursor.getString(3) + "\" and "
								+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN
								+ " = \"" + cursor.getString(1) + "\"", null);
			}
		} catch (SQLiteException ex) {
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
			}
		}

	}
	
	synchronized public String addCityNum(int cityId) {
    	android.util.Log.e("ALARM","CityDBManager.java || addCityInfo : "+cityId);
    	String uriStr2 = "";
    	SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentResolver resolver = mContext.getContentResolver();
		ContentValues values = new ContentValues();
		
		Cursor cursor = null;		
        int result = 0;
        int osbDaylight = 0;
        try {
	        cursor = database.rawQuery("SELECT "
						+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
						+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
						+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
						+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO + ", "
						+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
						+ DatabaseHelper.DATABASE_COLUMN_CITY_KO + ", "
						+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
						+ DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
						+ DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
						+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
						+ DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + ", "
						+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
						+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " FROM "
						+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
						+ DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);
			
			if (cursor != null && cursor.moveToFirst()) {
				String country = cursor.getString(2);
				String request = cursor.getString(12);
				osbDaylight = WeatherUtil.getTimeZoneDaylight(country, request);
			}
			
	        values.put(DatabaseHelper.DATABASE_COLUMN_SETTED, CITY_SET_SETTED);
	        values.put(DatabaseHelper.DATABASE_COLUMN_SETTED_TIME, System.currentTimeMillis());
	        values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, osbDaylight);
	        
	        if(database == null) return uriStr2;
        
	        result = database.update(DatabaseHelper.DATABASE_TABLE_NAME, values, 
	        							DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId,
	                                 null);
	        uriStr2 = insertContentProvider(database, cityId);
	        
	        setAddCityId(cityId);
        }catch(Exception e){
        	android.util.Log.e("ALARM","CityDBManager.java || addCityInfo : "+e.getMessage());
    	}finally {
    		if(cursor != null){
    			cursor.close();
    		}
    		if(database != null){
    			database.close();
    		}
        }
        if(result == 0) {
            return uriStr2;
        }
        return uriStr2;
    }

	private static void recreateContentProvider(Context context) {
		DatabaseHelper providerDatabaseHelper = new DatabaseHelper(context,
														DatabaseHelper.PROVIDER_DATABASE_NAME);
		SQLiteDatabase providerDatabase = providerDatabaseHelper.getWritableDatabase();
		providerDatabaseHelper.recreateProviderTable(providerDatabase);
		
		if(providerDatabase != null) {
			providerDatabase.close();
		}
	}

	private static void copyContentProviderFromWCDB(Context context){
		DatabaseHelper databaseHelper = new DatabaseHelper(context,
												DatabaseHelper.DATABASE_NAME);
		SQLiteDatabase database = databaseHelper.getReadableDatabase();
		ContentValues addedCityValue = new ContentValues();
		DatabaseHelper providerDatabaseHelper = new DatabaseHelper(context,
												DatabaseHelper.PROVIDER_DATABASE_NAME);
		SQLiteDatabase providerDatabase = providerDatabaseHelper.getWritableDatabase();
//		providerDatabaseHelper.recreateProviderTable(providerDatabase);
		
		Cursor cursor = null;
		String stringWhere = " WHERE " + DatabaseHelper.DATABASE_COLUMN_SETTED + " = " + CITY_SET_SETTED;
		String stringOrderBy = "ORDER BY " + DatabaseHelper.DATABASE_COLUMN_SETTED_TIME + " ASC";
		
		try{
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_BG + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_BG + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_HR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_HR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_CS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_CS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_DA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_DA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_NL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_NL_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FI + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FI + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_DE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_DE_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_HU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_HU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IT_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_MK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_MK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_NO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_NO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_PL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_PL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_PT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_RO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_RO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SV + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SV + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_TR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_TR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_RU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU_RIL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_RU_RIL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_AR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_AR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_CN + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_CN + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_TW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_TW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT_BR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_PT_BR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_RMX + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES_RMX + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_US + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_US + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_AU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_AU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_IE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_IE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_HK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_HK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_MS + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_MS + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_TH + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_TH + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_VI + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_VI + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_JA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_JA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR + ", " //[suhaeng.lee] add language es_AR for VIVO
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR  + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KK  + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_UK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_UK
					+ " FROM " + DatabaseHelper.DATABASE_TABLE_NAME + " "
					+ stringWhere
					+ " " + stringOrderBy, null);
			if (cursor != null && cursor.moveToFirst()) {
				do{
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN, cursor.getString(1));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO, cursor.getString(2));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY, cursor.getString(3));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN, cursor.getString(4));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_KO, cursor.getString(5));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY, cursor.getString(6));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, cursor.getString(7));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_GMT_VALUE, Integer.parseInt(cursor.getString(8)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LATITUDE, cursor.getString(9));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LONGITUDE, cursor.getString(10));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL, Integer.parseInt(cursor.getString(11)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION, Integer.parseInt(cursor.getString(12)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, Integer.parseInt(cursor.getString(13)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_REQUEST, cursor.getString(14));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_SETTED, Integer.parseInt(cursor.getString(15)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_BG, cursor.getString(16));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_BG, cursor.getString(17));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_HR, cursor.getString(18));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_HR, cursor.getString(19));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_CS, cursor.getString(20));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_CS, cursor.getString(21));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DA, cursor.getString(22));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DA, cursor.getString(23));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL, cursor.getString(24));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NL, cursor.getString(25));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL_BE, cursor.getString(26));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NL_BE, cursor.getString(27));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FI, cursor.getString(28));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FI, cursor.getString(29));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR, cursor.getString(30));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR, cursor.getString(31));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_BE, cursor.getString(32));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_BE, cursor.getString(33));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CH, cursor.getString(34));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_CH, cursor.getString(35));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE, cursor.getString(36));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DE, cursor.getString(37));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE_CH, cursor.getString(38));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DE_CH, cursor.getString(39));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EL, cursor.getString(40));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EL, cursor.getString(41));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_HU, cursor.getString(42));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_HU, cursor.getString(43));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IS, cursor.getString(44));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IS, cursor.getString(45));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT, cursor.getString(46));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IT, cursor.getString(47));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT_CH, cursor.getString(48));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IT_CH, cursor.getString(49));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_MK, cursor.getString(50));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_MK, cursor.getString(51));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NO, cursor.getString(52));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NO, cursor.getString(53));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PL, cursor.getString(54));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PL, cursor.getString(55));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT, cursor.getString(56));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PT, cursor.getString(57));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RO, cursor.getString(58));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RO, cursor.getString(59));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SR, cursor.getString(60));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SR, cursor.getString(61));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SK, cursor.getString(62));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SK, cursor.getString(63));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SL, cursor.getString(64));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SL, cursor.getString(65));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES, cursor.getString(66));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES, cursor.getString(67));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SV, cursor.getString(68));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SV, cursor.getString(69));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_TR, cursor.getString(70));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_TR, cursor.getString(71));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU, cursor.getString(72));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RU, cursor.getString(73));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU_RIL, cursor.getString(74));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RU_RIL, cursor.getString(75));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_AR, cursor.getString(76));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_AR, cursor.getString(77));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IW, cursor.getString(78));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IW, cursor.getString(79));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_CN, cursor.getString(80));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_CN, cursor.getString(81));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_TW, cursor.getString(82));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_TW, cursor.getString(83));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT_BR, cursor.getString(84));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PT_BR, cursor.getString(85));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_RMX, cursor.getString(86));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_RMX, cursor.getString(87));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CA, cursor.getString(88));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_CA, cursor.getString(89));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_US, cursor.getString(90));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_US, cursor.getString(91));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_AU, cursor.getString(92));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_AU, cursor.getString(93));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_CA, cursor.getString(94));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_CA, cursor.getString(95));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_IE, cursor.getString(96));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_IE, cursor.getString(97));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_HK, cursor.getString(98));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_HK, cursor.getString(99));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_MS, cursor.getString(100));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_MS, cursor.getString(101));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ID, cursor.getString(102));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ID, cursor.getString(103));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_TH, cursor.getString(104));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_TH, cursor.getString(105));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_VI, cursor.getString(106));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_VI, cursor.getString(107));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FA, cursor.getString(108));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FA, cursor.getString(109));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_JA, cursor.getString(110));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_JA, cursor.getString(111));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR, cursor.getString(112)); //[suhaeng.lee] add language es_AR for VIVO
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR, cursor.getString(113));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR, cursor.getString(114));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR, cursor.getString(115));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR, cursor.getString(116));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR, cursor.getString(117));
					
					providerDatabase.insert(DatabaseHelper.PROVIDER_DATABASE_TABLE_NAME, null, addedCityValue);
				} while (cursor.moveToNext());
			}			
		}catch (Exception e) {
			e.printStackTrace();
		}finally{
			if(cursor != null){
				cursor.close();
			}
			if(database != null){
				database.close();
			}
			if(providerDatabase != null) {
				providerDatabase.close();
			}
		}
	}

	private String insertContentProvider(SQLiteDatabase database, int cityId) {
		ContentResolver resolver = mContext.getContentResolver();
		ContentValues addedCityValue = new ContentValues();
		String uriStr2 = "";
		
		Cursor cursor = null;

		try {
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KO + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
					+ DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_BG + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_BG + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_HR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_HR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_CS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_CS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_DA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_DA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_NL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_NL_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FI + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FI + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR_BE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_DE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_DE_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_HU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_HU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IS + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IT_CH + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_MK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_MK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_NO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_NO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_PL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_PL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_PT + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_RO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_RO + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SK + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_SV + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_SV + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_TR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_TR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_RU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU_RIL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_RU_RIL + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_AR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_AR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_IW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_IW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_CN + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_CN + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_TW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_TW + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT_BR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_PT_BR + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_RMX + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES_RMX + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FR_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_US + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_US + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_AU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_AU + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_CA + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_IE + ", " 
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN_IE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_HK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_HK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_MS + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_MS + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_TH + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_TH + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_VI + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_VI + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_JA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_JA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR + ", " //[suhaeng.lee] add language es_AR for VIVO
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_UK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_UK
					+ " FROM " + DatabaseHelper.DATABASE_TABLE_NAME + " "
					+ "WHERE " + DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);

			if (cursor != null && cursor.moveToFirst()) {
				Log.message("Provider insert() - While S");
				do {
					// addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_ID,
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN, cursor.getString(1));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO, cursor.getString(2));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY, cursor.getString(3));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN, cursor.getString(4));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_KO, cursor.getString(5));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY, cursor.getString(6));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, cursor.getString(7));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_GMT_VALUE, Integer.parseInt(cursor.getString(8)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LATITUDE, cursor.getString(9));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LONGITUDE, cursor.getString(10));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL, Integer.parseInt(cursor.getString(11)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION, Integer.parseInt(cursor.getString(12)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, Integer.parseInt(cursor.getString(13)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_REQUEST, cursor.getString(14));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_SETTED, Integer.parseInt(cursor.getString(15)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_BG, cursor.getString(16));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_BG, cursor.getString(17));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_HR, cursor.getString(18));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_HR, cursor.getString(19));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_CS, cursor.getString(20));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_CS, cursor.getString(21));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DA, cursor.getString(22));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DA, cursor.getString(23));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL, cursor.getString(24));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NL, cursor.getString(25));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL_BE, cursor.getString(26));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NL_BE, cursor.getString(27));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FI, cursor.getString(28));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FI, cursor.getString(29));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR, cursor.getString(30));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR, cursor.getString(31));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_BE, cursor.getString(32));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_BE, cursor.getString(33));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CH, cursor.getString(34));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_CH, cursor.getString(35));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE, cursor.getString(36));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DE, cursor.getString(37));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE_CH, cursor.getString(38));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DE_CH, cursor.getString(39));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EL, cursor.getString(40));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EL, cursor.getString(41));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_HU, cursor.getString(42));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_HU, cursor.getString(43));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IS, cursor.getString(44));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IS, cursor.getString(45));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT, cursor.getString(46));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IT, cursor.getString(47));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT_CH, cursor.getString(48));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IT_CH, cursor.getString(49));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_MK, cursor.getString(50));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_MK, cursor.getString(51));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NO, cursor.getString(52));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NO, cursor.getString(53));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PL, cursor.getString(54));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PL, cursor.getString(55));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT, cursor.getString(56));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PT, cursor.getString(57));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RO, cursor.getString(58));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RO, cursor.getString(59));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SR, cursor.getString(60));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SR, cursor.getString(61));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SK, cursor.getString(62));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SK, cursor.getString(63));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SL, cursor.getString(64));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SL, cursor.getString(65));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES, cursor.getString(66));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES, cursor.getString(67));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SV, cursor.getString(68));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SV, cursor.getString(69));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_TR, cursor.getString(70));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_TR, cursor.getString(71));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU, cursor.getString(72));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RU, cursor.getString(73));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU_RIL, cursor.getString(74));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RU_RIL, cursor.getString(75));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_AR, cursor.getString(76));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_AR, cursor.getString(77));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IW, cursor.getString(78));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IW, cursor.getString(79));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_CN, cursor.getString(80));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_CN, cursor.getString(81));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_TW, cursor.getString(82));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_TW, cursor.getString(83));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT_BR, cursor.getString(84));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PT_BR, cursor.getString(85));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_RMX, cursor.getString(86));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_RMX, cursor.getString(87));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CA, cursor.getString(88));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_CA, cursor.getString(89));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_US, cursor.getString(90));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_US, cursor.getString(91));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_AU, cursor.getString(92));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_AU, cursor.getString(93));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_CA, cursor.getString(94));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_CA, cursor.getString(95));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_IE, cursor.getString(96));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_IE, cursor.getString(97));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_HK, cursor.getString(98));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_HK, cursor.getString(99));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_MS, cursor.getString(100));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_MS, cursor.getString(101));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ID, cursor.getString(102));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ID, cursor.getString(103));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_TH, cursor.getString(104));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_TH, cursor.getString(105));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_VI, cursor.getString(106));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_VI, cursor.getString(107));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FA, cursor.getString(108));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FA, cursor.getString(109));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_JA, cursor.getString(110));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_JA, cursor.getString(111));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR, cursor.getString(112)); //[suhaeng.lee] add language es_AR for VIVO
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR, cursor.getString(113));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_KK, cursor.getString(114));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_KK, cursor.getString(115));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_UK, cursor.getString(116));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_UK, cursor.getString(117));

				} while (cursor.moveToNext());
				Log.message("Provider insert() - While E");
			}

//			resolver.insert(WorldClockProvider.WORLDCLOCK_CONTENT_URI,
//					addedCityValue);			
			Uri uri = resolver.insert(WorldClockProvider.WORLDCLOCK_CONTENT_URI, addedCityValue);
			if (uri != null) {
				android.util.Log.d("ALARM","CityDBManager.java || insertContentProvider : "+uri.toString());
				String uriStr = uri.toString();
				uriStr2 = uriStr.substring(uriStr.lastIndexOf("/") + 1);
				android.util.Log.d("ALARM","CityDBManager.java || insertContentProvider : "+uriStr2);
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
			}
		}
		
		return uriStr2;

	}

	private void updateContentProvider(SQLiteDatabase database, int cityId) {
		ContentResolver resolver = mContext.getContentResolver();
		ContentValues addedCityValue = new ContentValues();

		Cursor cursor = null;
		try {
			cursor = database.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO + ", "
	                + DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY + ", "
	                + DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
	                + DatabaseHelper.DATABASE_COLUMN_CITY_KO + ", "
	                + DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY + ", "
	                + DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
	                + DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
	                + DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
	                + DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
	                + DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
	                + DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + ", "
	                + DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", "
	                + DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
	                + DatabaseHelper.DATABASE_COLUMN_SETTED + ", "
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_BG + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_BG + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_HR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_HR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_CS + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_CS + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_DA + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_DA + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_NL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL_BE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_NL_BE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_FI + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_FI + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_FR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_BE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_FR_BE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CH + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_FR_CH + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_DE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE_CH + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_DE_CH + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_EL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_EL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_HU + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_HU + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_IS + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_IS + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_IT + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT_CH + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_IT_CH + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_MK + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_MK + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_NO + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_NO + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_PL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_PL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_PT + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_RO + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_RO + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_SR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_SR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_SK + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_SK + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_SL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_SL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_ES + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_SV + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_SV + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_TR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_TR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_RU + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU_RIL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_RU_RIL + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_AR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_AR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_IW + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_IW + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_CN + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_ZH_CN + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_TW + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_ZH_TW + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT_BR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_PT_BR + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_RMX + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_ES_RMX + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CA + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_FR_CA + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_US + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_EN_US + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_AU + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_EN_AU + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_CA + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_EN_CA + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_IE + ", " 
	                + DatabaseHelper.DATABASE_COLUMN_CITY_EN_IE + ", "
	                + DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_HK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ZH_HK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_MS + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_MS + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ID + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_TH + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_TH + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_VI + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_VI + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_FA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_FA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_JA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_JA + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR + ", " //[suhaeng.lee] add language es_AR for VIVO
					+ DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_KK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_KK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_UK + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_UK
	                + " FROM " + DatabaseHelper.DATABASE_TABLE_NAME + " "
	                + "WHERE " + DatabaseHelper.DATABASE_COLUMN_ID + " = " + cityId, null);

			if (cursor != null && cursor.moveToFirst()) {
				Log.message("Provider insert() - While S");
				do {
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN, cursor.getString(1));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_KO, cursor.getString(2));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CHOSEONG_COUNTRY, cursor.getString(3));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN, cursor.getString(4));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_KO, cursor.getString(5));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CHOSEONG_CITY, cursor.getString(6));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, cursor.getString(7));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_GMT_VALUE, Integer.parseInt(cursor.getString(8)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LATITUDE, cursor.getString(9));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LONGITUDE, cursor.getString(10));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL, Integer.parseInt(cursor.getString(11)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION, Integer.parseInt(cursor.getString(12)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, Integer.parseInt(cursor.getString(13)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_REQUEST, cursor.getString(14));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_SETTED, Integer.parseInt(cursor.getString(15)));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_BG, cursor.getString(16));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_BG, cursor.getString(17));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_HR, cursor.getString(18));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_HR, cursor.getString(19));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_CS, cursor.getString(20));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_CS, cursor.getString(21));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DA, cursor.getString(22));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DA, cursor.getString(23));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL, cursor.getString(24));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NL, cursor.getString(25));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NL_BE, cursor.getString(26));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NL_BE, cursor.getString(27));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FI, cursor.getString(28));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FI, cursor.getString(29));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR, cursor.getString(30));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR, cursor.getString(31));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_BE, cursor.getString(32));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_BE, cursor.getString(33));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CH, cursor.getString(34));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_CH, cursor.getString(35));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE, cursor.getString(36));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DE, cursor.getString(37));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_DE_CH, cursor.getString(38));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_DE_CH, cursor.getString(39));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EL, cursor.getString(40));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EL, cursor.getString(41));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_HU, cursor.getString(42));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_HU, cursor.getString(43));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IS, cursor.getString(44));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IS, cursor.getString(45));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT, cursor.getString(46));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IT, cursor.getString(47));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IT_CH, cursor.getString(48));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IT_CH, cursor.getString(49));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_MK, cursor.getString(50));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_MK, cursor.getString(51));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_NO, cursor.getString(52));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_NO, cursor.getString(53));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PL, cursor.getString(54));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PL, cursor.getString(55));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT, cursor.getString(56));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PT, cursor.getString(57));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RO, cursor.getString(58));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RO, cursor.getString(59));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SR, cursor.getString(60));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SR, cursor.getString(61));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SK, cursor.getString(62));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SK, cursor.getString(63));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SL, cursor.getString(64));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SL, cursor.getString(65));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES, cursor.getString(66));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES, cursor.getString(67));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_SV, cursor.getString(68));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_SV, cursor.getString(69));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_TR, cursor.getString(70));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_TR, cursor.getString(71));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU, cursor.getString(72));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RU, cursor.getString(73));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_RU_RIL, cursor.getString(74));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_RU_RIL, cursor.getString(75));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_AR, cursor.getString(76));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_AR, cursor.getString(77));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_IW, cursor.getString(78));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_IW, cursor.getString(79));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_CN, cursor.getString(80));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_CN, cursor.getString(81));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_TW, cursor.getString(82));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_TW, cursor.getString(83));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_PT_BR, cursor.getString(84));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_PT_BR, cursor.getString(85));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_RMX, cursor.getString(86));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_RMX, cursor.getString(87));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FR_CA, cursor.getString(88));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FR_CA, cursor.getString(89));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_US, cursor.getString(90));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_US, cursor.getString(91));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_AU, cursor.getString(92));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_AU, cursor.getString(93));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_CA, cursor.getString(94));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_CA, cursor.getString(95));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN_IE, cursor.getString(96));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_EN_IE, cursor.getString(97));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ZH_HK, cursor.getString(98));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ZH_HK, cursor.getString(99));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_MS, cursor.getString(100));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_MS, cursor.getString(101));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ID, cursor.getString(102));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ID, cursor.getString(103));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_TH, cursor.getString(104));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_TH, cursor.getString(105));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_VI, cursor.getString(106));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_VI, cursor.getString(107));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_FA, cursor.getString(108));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_FA, cursor.getString(109));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_JA, cursor.getString(110));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_JA, cursor.getString(111));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_ES_AR, cursor.getString(112)); //[suhaeng.lee] add language es_AR for VIVO
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_ES_AR, cursor.getString(113));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_KK, cursor.getString(114));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_KK, cursor.getString(115));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_COUNTRY_UK, cursor.getString(116));
					addedCityValue.put(DatabaseHelper.DATABASE_COLUMN_CITY_UK, cursor.getString(117));
					Log.message("Provider insert() - While E : " + cursor.getString(4) + ", " + cursor.getString(4) + ", " + Integer.parseInt(cursor.getString(13)));
					resolver.update(WorldClockProvider.WORLDCLOCK_CONTENT_URI, addedCityValue, DatabaseHelper.DATABASE_COLUMN_CITY_EN + 
							" = \"" + cursor.getString(4) + "\" and " + 
							DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + 
							" = \"" + cursor.getString(1) + "\""
							, null);

				} while (cursor.moveToNext());
			}
			
		} catch (Exception e) {
			e.printStackTrace();
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
			}
		}

	}

	/*
	 * deleteSelectedWCItem parameter : ArrayList<CityInformation> city_list
	 * return : result (true or false) Description : Selected cities unregister
	 * to World Clock Main List not delete from DB
	 */
	public boolean deleteSelectedCity(ArrayList<CityInformation> city_list) {
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();
		CityInformation city;
		int result = 0;

		for (int i = 0; i < city_list.size(); i++) {
			city = city_list.get(i);

			values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, CITY_SET_NONE);
			values.put(DatabaseHelper.DATABASE_COLUMN_SETTED, CITY_SET_NONE);
			values.put(DatabaseHelper.DATABASE_COLUMN_SETTED_TIME,
					CITY_SET_NONE);
			values.put(DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE,
			        CITY_SET_NONE);

			result = database.update(DatabaseHelper.DATABASE_TABLE_NAME,
					values,
					DatabaseHelper.DATABASE_COLUMN_ID + " = " + city.getID(),
					null);

			deleteContentProvider(database, city.getID());
			deleteCityBroadCast(city, false);
			if (result == 0) {
				if (database != null)
					try {
						
					} catch (Exception e) {
						e.printStackTrace();
					} finally {
						database.close();
					}
					
				return false;
			}
		}
		if (database != null)
			try {
				
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				database.close();
			}	
		return true;
	}

	/*
	 * deleteAllWCItem return : result (true or false) Description : All cities
	 * unregister to World Clock Main List not delete from DB
	 */
	public boolean deleteAllCity() {
		if (mDatabaseHelper == null) {
			return false;
		}
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();

		values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, CITY_SET_NONE);
		values.put(DatabaseHelper.DATABASE_COLUMN_SETTED, CITY_SET_NONE);
		values.put(DatabaseHelper.DATABASE_COLUMN_SETTED_TIME, CITY_SET_NONE);
		values.put(DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE, CITY_SET_NONE);

		database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
				DatabaseHelper.DATABASE_COLUMN_SETTED + " = 1 ", null);

		deleteAllContentProvider();
		deleteCityBroadCast(null, true);
		if (database != null)
			try {
				
			} catch (Exception e) {
				e.printStackTrace();
			} finally {
				database.close();
			}

		return true;
	}

	/*
	 * deleteAllWCItem return : result (true or false) Description : All cities
	 * unregister to World Clock Main List not delete from DB
	 */
	public boolean isDuplicate(CityInformation city_info) {
		boolean isDuplicate = false;
		SQLiteDatabase database = mDatabaseHelper.getReadableDatabase();
		Cursor cursor = database.rawQuery(
				"SELECT count(" + DatabaseHelper.DATABASE_COLUMN_ID + ") "
						+ "FROM " + DatabaseHelper.DATABASE_TABLE_NAME + " "
						+ "WHERE " + DatabaseHelper.database_column_city
						+ " = \"" + city_info.getCityName() + "\"", null);

		try {
			if (cursor != null && cursor.moveToFirst()) {
				if (cursor.getInt(0) > 1)
					isDuplicate = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (cursor != null)
				cursor.close();
			if (database != null)
				database.close();
		}

		return isDuplicate;
	}

	protected void loadCityDataForList(Context context) {
		Log.message("loadCityDataForList() -- S");

		if (context == null)
			return;

		DatabaseHelper databaseHelper = new DatabaseHelper(context,
				DatabaseHelper.DATABASE_NAME);
		SQLiteDatabase databse = databaseHelper.getReadableDatabase();

		String stringWhere = "";
		String stringOrderBy = "";

		stringOrderBy = "ORDER BY " + DatabaseHelper.database_column_city
				+ " ASC";

		Cursor cursor = null;
		try {
			cursor = databse.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.database_column_city + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.database_column_country + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
					+ DatabaseHelper.DATABASE_COLUMN_GMT_VALUE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + " " + " FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " " + stringWhere
					+ " " + stringOrderBy, null);
			if (cursor != null && cursor.moveToFirst()) {
				Log.message("loadCityDataForList() - While S");
				do {
					CityInformation cityInfo = new CityInformation(
							cursor.getInt(0));

					cityInfo.setCityName(cursor.getString(1));
					cityInfo.setEnglishName(cursor.getString(2));
					cityInfo.setCountryName(cursor.getString(3));
					cityInfo.setEnglishCountryName(cursor.getString(4));
					cityInfo.setGmtString(cursor.getString(5));
					cityInfo.setGmtValue(cursor.getInt(6));
					cityInfo.setSummerTime(cursor.getInt(7));

					cityInfoAllList.add(cityInfo);

				} while (cursor.moveToNext());
				Log.message("loadCityDataForList() - While E");
			}
		} catch (Exception e) {
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				databse.close();
			}
		}

		Log.message("loadCityDataForList() -- E");
	}

	protected void loadCityDataForMap(Context context) {
		Log.message("loadMapCityData() -- S");
		DatabaseHelper databaseHelper = new DatabaseHelper(context,
				DatabaseHelper.DATABASE_NAME);
		SQLiteDatabase databse = databaseHelper.getReadableDatabase();

		String stringWhere = " WHERE "
				+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + " > 0";
		String stringOrderBy = "";

		Cursor cursor = null;
		try {
			cursor = databse.rawQuery("SELECT "
					+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
					+ DatabaseHelper.database_column_city + ", "
					+ DatabaseHelper.DATABASE_COLUMN_CITY_EN + ", "
					+ DatabaseHelper.database_column_country + ", "
					+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LATITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LONGITUDE + ", "
					+ DatabaseHelper.DATABASE_COLUMN_DISPLAY_LEVEL + ", "
					+ DatabaseHelper.DATABASE_COLUMN_LABEL_POSITION + " "
					+ " FROM " + DatabaseHelper.DATABASE_TABLE_NAME + " "
					+ stringWhere + " " + stringOrderBy, null);

			if (cursor != null && cursor.moveToFirst()) {
				Log.message("loadMapCityData() - While S");
				do {
					CityInformation cityInfo = new CityInformation(
							cursor.getInt(0));

					cityInfo.setCityName(cursor.getString(1));
					cityInfo.setEnglishName(cursor.getString(2));

					cityInfo.setCountryName(cursor.getString(3));
					cityInfo.setEnglishCountryName(cursor.getString(4));

					String latitude = cursor.getString(5);
					String longitude = cursor.getString(6);

					cityInfo.setLatitude(latitude);
					cityInfo.setLongitude(longitude);
					double degLatitude = Double.valueOf(DataManager
							.strToPolar(latitude));
					double degLongitude = Double.valueOf(DataManager
							.strToPolar(longitude));

					float[] vertex = DataManager.convertToCoordinate(
							degLatitude, degLongitude, 1.0f);

					cityInfo.setX(vertex[0]);
					cityInfo.setY(vertex[1]);
					cityInfo.setZ(vertex[2]);

					cityInfo.setDisplayLevel(cursor.getInt(7));
					cityInfo.setLabelPosition(cursor.getInt(8));

					cityInfoMapList.add(cityInfo);
				} while (cursor.moveToNext());
				Log.message("loadMapCityData() - While E");
			}
		} catch (Exception e) {
			e.printStackTrace();
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				databse.close();
			}
		}

		Log.message("loadMapCityData() -- E");
	}

	public static void deleteCityBroadCast(CityInformation city_info, boolean deleteAll) {
		Intent intent = new Intent(DELETE_WIDGET_URI);
		if (city_info != null) {
			android.util.Log.d(
					"ALARM",
					"[SEND]deleteCityBroadCast " + "["
							+ city_info.getCityName() + "]" + "["
							+ city_info.getCountryName() + "]");
			intent.putExtra("city_name", city_info.getCityName());
			intent.putExtra("country_name", city_info.getCountryName());
		}
		intent.putExtra("deleteAll", deleteAll);
		mContext.sendBroadcast(intent);
	}
	
	public static void refreshAddedCity(){	
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();
		Cursor cursor = null;
		String mGmt = null;
		String mNewGmtTime = null;
		
		try{
			cursor = database.rawQuery("SELECT "
						+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
						+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
						+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
						+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", " 
						+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " FROM "
						+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " = 1 AND "
						+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " = 0 ", null);
			if (cursor != null && cursor.moveToFirst()) {
				do{
					int mDayLight = cursor.getInt(3);
					int mNewDST = WeatherUtil.getTimeZoneDaylight(cursor.getString(2), cursor.getString(4));
					if(mDayLight != mNewDST){
						mGmt = cursor.getString(1);
						int mGmtHour = -1;
						int mGmtMinute = -1;
						String mSign = null;
						String newGmtHour = null;
						String newGmtMinute = null;
						String newGmt[] = mGmt.split(" ");
						String mGmt2 = newGmt[2];
						int mSize = newGmt[2].length();
						if(mSize > 3){
							String newGmtSplit[] = mGmt2.split(":");
							mGmtHour = Integer.parseInt(newGmtSplit[0]);
							mGmtMinute = Integer.parseInt(newGmtSplit[1]);
						}else{
							mGmtHour = Integer.parseInt(newGmt[2]);
						}
						mSign = newGmt[1];
						if(mNewDST == 1){
							if(mSign.equals("+")){
								mGmtHour = mGmtHour + 1;
							}else{
								mGmtHour = mGmtHour - 1;
							}
						}else{
							if(mSign.equals("+")){
								mGmtHour = mGmtHour - 1;
							}else{
								mGmtHour = mGmtHour + 1;
							}
						}
						if(mGmtMinute == -1){
							newGmtHour = Integer.toString(mGmtHour);
							mNewGmtTime = newGmt[0] + " " + newGmt[1] + " " +newGmtHour;
						}else{
							newGmtHour = Integer.toString(mGmtHour);
							newGmtMinute = Integer.toString(mGmtMinute);
							mNewGmtTime = newGmt[0] + " " + newGmt[1] + " " +newGmtHour + ":" + newGmtMinute;
						}

						values.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, mNewGmtTime);
						values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, mNewDST);
						database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
								DatabaseHelper.DATABASE_COLUMN_ID + " = " + cursor.getInt(0), null);
					}
					
				}while(cursor.moveToNext());
			}
		}catch (Exception e) {
			e.printStackTrace();
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				database.close();
			}
		}
	}
	
	public static boolean checkList(){
		if (mDatabaseHelper == null) {
			return false;
		}
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		Cursor cursor = null;
		
		boolean isExistList = false;
		
		try{
			cursor = database.rawQuery("SELECT "
						+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
						+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
						+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
						+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " FROM "
						+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " = 1", null);
			
			if (cursor != null) {
				isExistList = true;
			}else{
				isExistList = false;
			}
		}catch (Exception e) {
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
				database.close();
			}
		}
		return isExistList;
	}
	
	public void updateDST(){
		SQLiteDatabase database = mDatabaseHelper.getWritableDatabase();
		ContentValues values = new ContentValues();
		Cursor cursor = null;
		String mGmt = null;
		String mNewGmtTime = null;
		
		try{
			cursor = database.rawQuery("SELECT "
						+ DatabaseHelper.DATABASE_COLUMN_ID + ", "
						+ DatabaseHelper.DATABASE_COLUMN_GMT_TEXT + ", "
						+ DatabaseHelper.DATABASE_COLUMN_COUNTRY_EN + ", "
						+ DatabaseHelper.DATABASE_COLUMN_DAYLIGHT + ", " 
						+ DatabaseHelper.DATABASE_COLUMN_REQUEST + ", "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " FROM "
						+ DatabaseHelper.DATABASE_TABLE_NAME + " " + "WHERE "
						+ DatabaseHelper.DATABASE_COLUMN_SETTED + " = 1 AND "
						+ DatabaseHelper.DATABASE_COLUMN_UPDATE_MODE + " = 0 ", null);
			if (cursor != null && cursor.moveToFirst()) {
				do{
					int mDayLight = cursor.getInt(3);
					int mNewDST = WeatherUtil.getTimeZoneDaylight(cursor.getString(2), cursor.getString(4));
					if(mDayLight != mNewDST){
						mGmt = cursor.getString(1);
						int mGmtHour = -1;
						int mGmtMinute = -1;
						String mSign = null;
						String newGmtHour = null;
						String newGmtMinute = null;
						String newGmt[] = mGmt.split(" ");
						String mGmt2 = newGmt[2];
						int mSize = newGmt[2].length();
						if(mSize > 3){
							String newGmtSplit[] = mGmt2.split(":");
							mGmtHour = Integer.parseInt(newGmtSplit[0]);
							mGmtMinute = Integer.parseInt(newGmtSplit[1]);
						}else{
							mGmtHour = Integer.parseInt(newGmt[2]);
						}
						mSign = newGmt[1];
						if(mNewDST == 1){
							if(mSign.equals("+")){
								mGmtHour = mGmtHour + 1;
							}else{
								mGmtHour = mGmtHour - 1;
							}
						}else{
							if(mSign.equals("+")){
								mGmtHour = mGmtHour - 1;
							}else{
								mGmtHour = mGmtHour + 1;
							}
						}
						if(mGmtMinute == -1){
							newGmtHour = Integer.toString(mGmtHour);
							mNewGmtTime = newGmt[0] + " " + newGmt[1] + " " +newGmtHour;
						}else{
							newGmtHour = Integer.toString(mGmtHour);
							newGmtMinute = Integer.toString(mGmtMinute);
							mNewGmtTime = newGmt[0] + " " + newGmt[1] + " " +newGmtHour + ":" + newGmtMinute;
						}

						values.put(DatabaseHelper.DATABASE_COLUMN_GMT_TEXT, mNewGmtTime);
						values.put(DatabaseHelper.DATABASE_COLUMN_DAYLIGHT, mNewDST);
						database.update(DatabaseHelper.DATABASE_TABLE_NAME, values,
								DatabaseHelper.DATABASE_COLUMN_ID + " = " + cursor.getInt(0), null);
						updateContentProvider(database, cursor.getInt(0));
					}
					
				}while(cursor.moveToNext());
			}
		}catch (Exception e) {
			e.printStackTrace();
			Log.message("DB error in CityDBManager");
		} finally {
			if (cursor != null) {
				cursor.close();
			}
			if (database != null) {
				database.close();
			}			
		}
	}
	
	// [suhaeng.lee][1456] 2011.10.19 START
	public static boolean checkDeleteList(Context context, int selectedID){
		boolean mCheckDeleteList = false;
		SQLiteDatabase database = null;
		Cursor cursor = null;
		try {
			DatabaseHelper DbHelper = new DatabaseHelper(context, DatabaseHelper.DATABASE_NAME);
			database = DbHelper.getReadableDatabase();
			android.util.Log.i("123456789", "selectedID => " + selectedID);
			cursor = database.rawQuery("SELECT COUNT(*) FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " WHERE _id = " + selectedID + " AND " + DatabaseHelper.DATABASE_COLUMN_SETTED + " = 1", null);
			if (cursor != null && cursor.moveToNext()) {
				if (cursor.getInt(0) > 0) {
					mCheckDeleteList = true;
				}
			}
		} catch (SQLiteException e) {
			mCheckDeleteList = false;
		} finally {
			if (cursor != null)
				cursor.close();
			if (database != null)
				database.close();
		}
		return mCheckDeleteList;
	}
	
	public static boolean checkDeleteAllList(Context context){
		boolean mCheckDeleteList = false;
		SQLiteDatabase database = null;
		Cursor cursor = null;
		try {
			DatabaseHelper DbHelper = new DatabaseHelper(context, DatabaseHelper.DATABASE_NAME);
			database = DbHelper.getReadableDatabase();
			cursor = database.rawQuery("SELECT COUNT(*) FROM "
					+ DatabaseHelper.DATABASE_TABLE_NAME + " WHERE " + DatabaseHelper.DATABASE_COLUMN_SETTED + " = 1", null);
			if (cursor != null && cursor.moveToNext()) {
				if (cursor.getInt(0) > 0) {
					mCheckDeleteList = true;
				}
			}
		} catch (SQLiteException e) {
			mCheckDeleteList = false;
		} finally {
			if (cursor != null)
				cursor.close();
			if (database != null)
				database.close();
		}
		return mCheckDeleteList;
	}
	// [suhaeng.lee][1456] 2011.10.19 END

}